package com.qyhl.webtv.module_user.share;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.gyf.immersionbar.ImmersionBar;
import com.qyhl.webtv.basiclib.base.BaseActivity;
import com.qyhl.webtv.basiclib.base.BaseIViewPresenter;
import com.qyhl.webtv.basiclib.utils.glide.GlideCircleTransform;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.constant.ARouterPathConstant;
import com.qyhl.webtv.module_user.R;
import com.qyhl.webtv.module_user.R2;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = ARouterPathConstant.SHARE_FACINGTWO)
public class ShareFacingtwo extends BaseActivity {
    @BindView(R2.id.userImg)
    ImageView userImg;
    @BindView(R2.id.username)
    TextView username;
    @BindView(R2.id.describe2)
    TextView describe2;
    @BindView(R2.id.qrimg)
    ImageView qrimg;
    @BindView(R2.id.share_code)
    TextView share_code;

    private UserShareUtil shareUtil;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected int getContentView() {
        return R.layout.login_activity_share_qrcode;
    }

    @Override
    protected void setImmersionBar(ImmersionBar mImmersionBar) {
        setDefaultImmerBar();
    }

    @Override
    protected BaseIViewPresenter initBaseIViewPresenter() {
        return null;
    }

    @Override
    protected void init() {
        initview();
    }

    @Override
    protected void setListener() {

    }


    private void initview() {
        describe2.setText("立刻扫码，我在" + getString(R.string.app_name) + "等你");
        String headicon = CommonUtils.getInstance().getUserLogo();
        Glide.with(ShareFacingtwo.this)
                .load(headicon)
                .apply(new RequestOptions()
                        .centerCrop()
                        .error(R.drawable.comment_head_default)
                        .transform(new GlideCircleTransform(ShareFacingtwo.this)))
                .into(userImg);
        String code = CommonUtils.getInstance().getCode();
        share_code.setText(code);

        String nickName = CommonUtils.getInstance().getNickName();
        username.setText(nickName);

        shareUtil = new UserShareUtil(this, 200, qrimg);
    }

    @OnClick({R2.id.back, R2.id.share_circle, R2.id.share_wechat, R2.id.share_qq, R2.id.share_message, R2.id.share_code_copy})
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.back) {
            finish();

        } else if (i == R.id.share_circle) {
            shareUtil.share("Circle");

        } else if (i == R.id.share_wechat) {
            shareUtil.share("WeiXin");

        } else if (i == R.id.share_qq) {
            shareUtil.share("QQ");

        } else if (i == R.id.share_message) {
            shareUtil.sendSMS();

        } else if (i == R.id.share_code_copy) {
            shareUtil.clipBoard();

        } else {
        }
    }

    @Override
    protected void onDestroy() {
        shareUtil.onDestroy();
        super.onDestroy();
    }


}
